import { Divider } from 'antd';
import {Suspense} from "react"
// imbrc
import { Route, Switch, NavLink, Link ,Redirect} from 'react-router-dom'
let RouterView = (props)=>{
    console.log(props);
    let { RouterList } = props
    let routerlist = RouterList.filter((item) => {
        return !item.to
    })
    let redirect = RouterList.filter(item => item.to)[0]
    console.log(routerlist,redirect);
    return (
        <Suspense fallback={<div>...loading</div>}>
            <Switch>
                {
                    routerlist && routerlist.length?routerlist.map((item,index)=>{
                        return <Route path={item.path} key={index} render={(routerProps)=>{
                            return <item.component {...routerProps}></item.component>
                        }}></Route>
                    }):"暂无路由"
                }
                {
                    redirect?<Redirect from={redirect.from} to={redirect.to}> </Redirect>:"暂无重定向"
                }

            </Switch>
        </Suspense>
       
    )
}
export default RouterView